From: Marco Trevisan (TreviƱo) Date: Fri, 3 May 2024 16:13:37 +0000 (+0200) Subject: js/environment: Always use Shell.util_spawn_async functions if possible X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~263^2^2~1 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=b910cc62de6c52399b6c500e4189286a67d466ca;p=gnome-shell.git js/environment: Always use Shell.util_spawn_async functions if possible If no child setup is provided then all the shell extensions that use GLib.spawn_async should actually use the shell spawning utils since we are supposed to always restore the default nofile rlimit on launched children. Part-of: (cherry picked from commit 64edd7940d97da368f4deb5af2446ad0e2909bdb) --- diff --git a/js/ui/environment.js b/js/ui/environment.js index 4ce70367e..24e52d739 100644 --- a/js/ui/environment.js +++ b/js/ui/environment.js @@ -348,14 +348,17 @@ if (slowdownEnv) { function wrapSpawnFunction(func) { const originalFunc = GLib[func]; return function (workingDirectory, argv, envp, flags, childSetup, ...args) { + const commonArgs = [workingDirectory, argv, envp, flags]; if (childSetup) { logError(new Error(`Using child GLib.${func} with a GLib.SpawnChildSetupFunc ` + 'is unsafe and may dead-lock, thus it should never be used from JavaScript. ' + `Shell.${func} can be used to perform default actions or an ` + 'async-signal-safe alternative should be used instead')); + return originalFunc(...commonArgs, childSetup, ...args); } - return originalFunc(workingDirectory, argv, envp, flags, childSetup, ...args); + const retValue = Shell[`util_${func}`](...commonArgs, ...args); + return [true, ...Array.isArray(retValue) ? retValue : [retValue]]; }; } GLib.spawn_async = wrapSpawnFunction('spawn_async');